<?php
include_once "PDO.class.php";
$mysql = new Db();
$curl = curl_init('https://www.lagou.com/zhaopin/PHP/?labelWords=label'); 
curl_setopt($curl, CURLOPT_FAILONERROR, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);   
$result = curl_exec($curl); 
$preg = '# <li class="con_list_item default_list" .*>.*<h3>(.*)</h3>.*<span class="money">(.*)</span>.*<!--<i></i>-->(.*)</div>.*<a href=".*>(.*)</a>.*</li>#isU';
preg_match_all($preg,$result,$arr);
// echo $result; 
//print_r($arr);
foreach($arr as $k=>$v){
    $data['work'] = $arr[1][$k];
    $data['money'] = $arr[4][$k];
    $data['job'] = $arr[1][$k];
    $data['age'] = $arr[3][$k];
    $query = $mysql->add('works',$data);
}

//print_r($data);
?>
